/****************************************************************************
	This file is part of Basqet.

	Basqet is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	Basqet is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
    along with Basqet.  If not, see <http://www.gnu.org/licenses/>.

****************************************************************************/

#include "richtextedittoolbar.h"


RichTextEditToolBar::RichTextEditToolBar(QWidget * parent /*= 0*/)
		:QToolBar("Formating", parent)
{
	populate();

}

void RichTextEditToolBar::populate()
{
	pBold = new QAction(QIcon(":/actions/format-text-bold.png"), "Bold", this);
	addAction(pBold.data());
	connect(pBold.data(), SIGNAL(triggered()), this, SIGNAL(actionBold()));

	pItalic = new QAction(QIcon(":/actions/format-text-italic.png"), "Italic", this);
	addAction(pItalic.data());
	connect(pItalic.data(), SIGNAL(triggered()), this, SIGNAL(actionItalic()));

	pUnderline = new QAction(QIcon(":/actions/format-text-underline.png"), "Underline", this);
	addAction(pUnderline.data());
	connect(pUnderline.data(), SIGNAL(triggered()), this, SIGNAL(actionUnderline()));

	pStrikethrough = new QAction(QIcon(":/actions/format-text-strikethrough.png"), "Mark as Delete", this);
	addAction(pStrikethrough.data());
	connect(pStrikethrough.data(), SIGNAL(triggered()), this, SIGNAL(actionStrikethrough()));

	addSeparator();

	pIncSize = new QAction(QIcon(":/actions/format-font-size-more.png"), "Size +", this);
	addAction(pIncSize.data());
	connect(pIncSize.data(), SIGNAL(triggered()), this, SIGNAL(actionIncSize()));

	pDecSize = new QAction(QIcon(":/actions/format-font-size-less.png"),"Size -", this);
	addAction(pDecSize.data());
	connect(pDecSize.data(), SIGNAL(triggered()), this, SIGNAL(actionDecSize()));

	addSeparator();

	pAdjustLeft = new QAction(QIcon(":/actions/format-justify-left.png"), "Left", this);
	addAction(pAdjustLeft.data());
	connect(pAdjustLeft.data(), SIGNAL(triggered()), this, SIGNAL(actionAdjustLeft()));

	pAdjustMid = new QAction(QIcon(":/actions/format-justify-center.png"), "Center", this);
	addAction(pAdjustMid.data());
	connect(pAdjustMid.data(), SIGNAL(triggered()), this, SIGNAL(actionAdjustMid()));

	pAdjustRight = new QAction(QIcon(":/actions/format-justify-right.png"), "Right", this);
	addAction(pAdjustRight.data());
	connect(pAdjustRight.data(), SIGNAL(triggered()), this, SIGNAL(actionAdjustRight()));

	disableActions();

}


void RichTextEditToolBar::enableActions()
{
	setActionsEnabled(true);
}

void RichTextEditToolBar::disableActions()
{
	setActionsEnabled(false);
}

void RichTextEditToolBar::setActionsEnabled(bool enabled)
{
	pBold->setEnabled(enabled);
	pItalic->setEnabled(enabled);
	pUnderline->setEnabled(enabled);
	pStrikethrough->setEnabled(enabled);
	pIncSize->setEnabled(enabled);
	pDecSize->setEnabled(enabled);
	pAdjustLeft->setEnabled(enabled);
	pAdjustMid->setEnabled(enabled);
	pAdjustRight->setEnabled(enabled);

}

